package com.yangguang.controller;

import com.yangguang.service.ExamService;
import com.yangguang.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("exam")
@RestController
@CrossOrigin
public class ExamController {
    @Autowired
    private ExamService examService;

    @PostMapping("addExam")
    public Result addExam(@RequestParam("examName") String examName, @RequestParam("subjectId") Integer subjectId, @RequestParam("subjectiveNumber") Integer subjectiveNumber, @RequestParam("objectiveNumber") Integer objectiveNumber) {
        if (examName == null || subjectId == null || subjectiveNumber == null || objectiveNumber == null) {
            return new Result(false, "有参数为空", null);
        }
        boolean b = examService.insertExam(examName, subjectId, subjectiveNumber, objectiveNumber);
        if (b) {
            return new Result(true, "添加成功", null);
        } else {
            return new Result(false, "添加失败", null);
        }
    }
}
